package com.example.shardingspheredemo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.shardingspheredemo.entity.OrderVo;
import com.example.shardingspheredemo.entity.TOrder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ClassName: OrderMapper
 * @Description:
 * @Date 2024/04/17 17:45
 * @Author songshaoqiu
 **/
@Mapper
public interface OrderMapper extends BaseMapper<TOrder> {

    @Select(value = {"SELECT\n" +
            "\tt1.order_no as 'orderNo',\n" +
            "\tsum( t2.count * t2.price ) as 'totalAmount'\n" +
            "FROM\n" +
            "\tt_order t1\n" +
            "\tJOIN t_order_item t2 ON t1.order_no = t2.order_no \n" +
            "GROUP BY\n" +
            "\tt1.order_no"})
    List<OrderVo> selectByCondition();
}
